<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <table>
            <thead>
                <tr>
                    <th>书名</th>
                    <th>价格</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="item in books">
                    <td>{{item.name}}</td>
                    <td>{{item.price}}</td>
                </tr>
            </tbody>
        </table>
        <h2>总价：{{all}}</h2>

    </div>

    <script src="./vue.js"></script>
    <script>
        let app=new Vue({
            el:"#app",
            data:{
                books:[
                    {name:"《高级程序设计》",price:49.9},
                    {name:"《成语大全》",price:29.9},
                    {name:"《辞海》",price:59.9},
                    {name:"《CSS指南》",price:49.9},
                ]
            },
            computed:{
                all(){
                    let a=0;
                    this.books.forEach(item => {
                        a+=item.price;
                    });
                    return a;
                }
            }
        })
    </script>
</body>
</html>